#include "client_socket.h"
#include "socket_exception.h"
#include "http_client.h"
#include <iostream>
#include <string>


int main ( void )
{
	try
	{

		//ClientSocket client_socket ( "localhost", 30000 );
		HttpClient vote( "218.5.113.240", 80 );

		std::string reply;
		std::string res;

		try
		{
			//client_socket << "Test message.";
			vote << "GET //html/58/n-58.html HTTP/1.0\r\nAccept: */*\r\nAccept-Language: zh-cn\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\r\nHost: www.china-shufajia.com\r\nConnection: Keep-Alive\r\n\r\n";
			//client_socket >> reply;
			while (1)
			{
			vote >> reply;
			res += reply;
			std::cout << "We received this response from the server:\n\"" << res << "\"\n";;
			}
		}
		catch ( SocketException& ) {}


	}
	catch ( SocketException& e )
	{
		std::cout << "Exception was caught:" << e.description() << "\n";
	}

	return 0;
}

